// 管理mock数据
const result = [
    {
        auditJoinId: '1',
        teacherId: '100001',
        teacherAccount: '100001',
        teacherName: '张三',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '2',
        teacherId: '100002',
        teacherAccount: '100002',
        teacherName: '李四',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '3',
        teacherId: '100003',
        teacherAccount: '100003',
        teacherName: '王二蛋',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '4',
        teacherId: '100004',
        teacherAccount: '100004',
        teacherName: '张三三',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '5',
        teacherId: '100005',
        teacherAccount: '100005',
        teacherName: '张是三',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '6',
        teacherId: '100006',
        teacherAccount: '100006',
        teacherName: '张三发',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '7',
        teacherId: '100007',
        teacherAccount: '100007',
        teacherName: '张三是',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '8',
        teacherId: '100008',
        teacherAccount: '100008',
        teacherName: '张三',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '9',
        teacherId: '10009',
        teacherAccount: '10009',
        teacherName: '张安抚',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '10',
        teacherId: '1000010',
        teacherAccount: '1000010',
        teacherName: '张三',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '11',
        teacherId: '1000011',
        teacherAccount: '1000011',
        teacherName: '张三',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '12',
        teacherId: '1000012',
        teacherAccount: '1000012',
        teacherName: '李四',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '13',
        teacherId: '1000013',
        teacherAccount: '1000013',
        teacherName: '王二蛋',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '14',
        teacherId: '1000014',
        teacherAccount: '1000014',
        teacherName: '张三三',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '15',
        teacherId: '1000015',
        teacherAccount: '1000015',
        teacherName: '张是三',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '16',
        teacherId: '1000016',
        teacherAccount: '1000016',
        teacherName: '张三发',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '17',
        teacherId: '1000017',
        teacherAccount: '1000017',
        teacherName: '张三是',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '18',
        teacherId: '1000018',
        teacherAccount: '1000018',
        teacherName: '张三',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '19',
        teacherId: '100019',
        teacherAccount: '100019',
        teacherName: '张安抚',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
    {
        auditJoinId: '20',
        teacherId: '1000020',
        teacherAccount: '1000020',
        teacherName: '张三',
        courseGroupId:'12423',
        courseGroupTime:'2018-2019第二学期',
        course:'操作系统',
        result: 1
    },
]

export default {
    //返回的数据生成
    auditJoinGet(options){
        //console.log(options);
        //根据rows的不同，返回的数据数不同
        let len = parseInt(options.url.match(/rows=(\S*)&/)[1]);
        //console.log(len);
        return{
            code: 1,
            msg: "返回结果成功",
            data: {
                total: 100,
                auditJoinInfo: result.slice(0,len)
            }
        }
    },
    auditJoinOperate(options){
        //console.log(options);
        let auditJoinId = options.url.match(/auditJoinId=(\S*)/)[1];
        let operateResult=parseInt(options.url.match(/result=(\S*)&/)[1]);
        for(let i of result){
            if(i.auditJoinId===auditJoinId){
                i.result=operateResult;
                break;
            }
        }
        return{
            code: 1,
            msg: "返回结果成功",
            data: {
            }
        }
    },
    auditJoinBatchOperate(options){
        //console.log(options);
        let str=options.body.split('&');
        let operationResult;
        let auditJoinIds=[];
        for(let i of str){
            if(!i.includes('token')){
                if(i.includes('result')){
                    operationResult=parseInt(i.match(/result=(\S*)/)[1]);
                }else{
                    auditJoinIds.push(i.match(/%5D=(\S*)/)[1]);
                }
            }
        }

        for(let i of auditJoinIds){
            for(let j of result){
                if(j.auditJoinId===i){
                    j.result=operationResult;
                    break;
                }
            }
        }
        return{
            code: 1,
            msg: "返回结果成功",
            data: {
            }
        }
    },
    getCourseGroupInfo:{
        code: 1,
        msg: "返回结果成功",
        data: {
            //随机生成数据
            courseGroupInfo:{
                courseGroupId: /[0-9]{6,7}/,
                course:'操作系统',
                courseGroupTime:'2018-2019第二学期',
                teachers:[
                    {
                        teacherName:'张三',
                        teacherId: '12324'
                    },
                    {
                        teacherName:'李四',
                        teacherId: '12323'
                    },
                    {
                        teacherName:'王五',
                        teacherId: '23435'
                    },
                    {
                        teacherName:'赵六',
                        teacherId: '345678'
                    }

                ],
                classes:[
                    {
                        className:'2018级计算机科学与技术1班',
                        classId: '1233'
                    },
                    {
                        className:'2018级计算机科学与技术2班',
                        classId: '1232343'
                    },
                    {
                        className:'2018级计算机科学与技术3班',
                        classId: '345'
                    },
                    {
                        className:'2018级计算机科学与技术4班',
                        classId: '12343'
                    },
                ],
                courseGroupName:'2018-2019第二学期操作系统课程组',
                courseGroupLeader:'张三',
            }
        }
    },
}
